home *** CD-ROM | disk | FTP | other *** search
- Path: iconet.hongkong.net!wong.yuk.wah%f18.n1000.z128
- From: wong.yuk.wah%f18.n1000.z128@iconet.hongkong.net (Wong Yuk Wah)
- Newsgroups: comp.lang.c
- Subject: *** AMENDMENT: Date Arithmetic ***
- Distribution: world
- Message-ID: <56cef1ea56cef1ea@iconet.hongkong.net>
- Date: Sun, 25 Feb 1996 12:22:00 HKT
- Organization: IcoNET (HONG KONG) <--> Internet gateway
- X-Mailer: MailGate 0.25+
- Reply-To: Wong Yuk Wah <Wong.Yuk.Wah%f18.n1000.z128@iconet.hongkong.net>
-
- Hi,
-
- In my previous message "Date Arithmetic" in this area, I mentioned how
- to increment a date by a specified number of days. However, I've found
- I'd made a *serious* mistake. I forgot to increment the YEAR!! Here is
- the amendment.
-
- i.e. From this fragment from function add_day...
-
-
- else {
- temp.month++;
-
- if (temp.month == 2)
- days_of_next_month = temp.year % 4 == 0 &&
- (temp.year % 100 != 0 ||
- temp.year % 400 == 0) ? 29 : 28;
- else
- days_of_next_month = days_of_month[temp.month];
-
-
- ...to this...
-
-
- else {
- temp.month++;
-
- if (temp.month > 12) { /* Incrementing the year */
- temp.year++;
- temp.month = 1;
- }
-
- if (temp.month == 2)
- days_of_next_month = temp.year % 4 == 0 &&
- (temp.year % 100 != 0 ||
- temp.year % 400 == 0) ? 29 : 28;
- else
- days_of_next_month = days_of_month[temp.month];
-
-
- I'm sorry for any inconvenience caused (especially for those who have
- seen my message!).
-
- Regards,
- Wong Yuk Wah
-
- * Origin: IcoNET <--> Internet/Usenet gateway, 128:1000/1 (128:1000/1)
-